home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Database How-To / Visual Basic 4 Database - How-to (The Waite Group)(1995).iso / validbnd.fr_ / validbnd.fr
Text File  |  1995-07-04  |  5KB  |  167 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Bound Browser II"
  5.    ClientHeight    =   2745
  6.    ClientLeft      =   1440
  7.    ClientTop       =   2325
  8.    ClientWidth     =   6420
  9.    BeginProperty Font 
  10.       name            =   "MS Sans Serif"
  11.       charset         =   0
  12.       weight          =   700
  13.       size            =   8.25
  14.       underline       =   0   'False
  15.       italic          =   0   'False
  16.       strikethrough   =   0   'False
  17.    EndProperty
  18.    Height          =   3435
  19.    Left            =   1380
  20.    LinkTopic       =   "Form1"
  21.    ScaleHeight     =   2745
  22.    ScaleWidth      =   6420
  23.    Top             =   1695
  24.    Width           =   6540
  25.    Begin VB.TextBox txtISBN 
  26.       DataField       =   "ISBN"
  27.       DataSource      =   "dtaTitles"
  28.       Height          =   315
  29.       Left            =   1860
  30.       MaxLength       =   13
  31.       TabIndex        =   2
  32.       Top             =   1380
  33.       Width           =   1635
  34.    End
  35.    Begin VB.TextBox txtYearPublished 
  36.       DataField       =   "Year Published"
  37.       DataSource      =   "dtaTitles"
  38.       Height          =   285
  39.       Left            =   1860
  40.       TabIndex        =   1
  41.       Top             =   900
  42.       Width           =   735
  43.    End
  44.    Begin VB.TextBox txtTitle 
  45.       DataField       =   "Title"
  46.       DataSource      =   "dtaTitles"
  47.       Height          =   555
  48.       Left            =   1860
  49.       MultiLine       =   -1  'True
  50.       TabIndex        =   0
  51.       Top             =   180
  52.       Width           =   4095
  53.    End
  54.    Begin VB.Data dtaTitles 
  55.       Caption         =   "Titles"
  56.       Connect         =   "Access"
  57.       DatabaseName    =   "C:\VB\BIBLIO.MDB"
  58.       Exclusive       =   0   'False
  59.       Height          =   300
  60.       Left            =   660
  61.       Options         =   0
  62.       ReadOnly        =   0   'False
  63.       RecordsetType   =   1  'Dynaset
  64.       RecordSource    =   "Titles"
  65.       Top             =   2040
  66.       Width           =   1815
  67.    End
  68.    Begin VB.Label Label3 
  69.       AutoSize        =   -1  'True
  70.       BackColor       =   &H00C0C0C0&
  71.       Caption         =   "ISBN:"
  72.       Height          =   195
  73.       Left            =   1200
  74.       TabIndex        =   5
  75.       Top             =   1440
  76.       Width           =   510
  77.    End
  78.    Begin VB.Label Label2 
  79.       AutoSize        =   -1  'True
  80.       BackColor       =   &H00C0C0C0&
  81.       Caption         =   "Year Published:"
  82.       Height          =   195
  83.       Left            =   360
  84.       TabIndex        =   4
  85.       Top             =   960
  86.       Width           =   1350
  87.    End
  88.    Begin VB.Label Label1 
  89.       AutoSize        =   -1  'True
  90.       BackColor       =   &H00C0C0C0&
  91.       Caption         =   "Title:"
  92.       Height          =   195
  93.       Left            =   1200
  94.       TabIndex        =   3
  95.       Top             =   180
  96.       Width           =   450
  97.    End
  98.    Begin VB.Menu mnuFile 
  99.       Caption         =   "&File"
  100.       Begin VB.Menu mnuFileExit 
  101.          Caption         =   "E&xit"
  102.       End
  103.    End
  104. End
  105. Attribute VB_Name = "Form1"
  106. Attribute VB_Creatable = False
  107. Attribute VB_Exposed = False
  108. Option Explicit
  109.  
  110. Private UpdateCancelled As Boolean
  111.  
  112. Private Sub dtaTitles_Validate(Action As Integer, Save As Integer)
  113.     Dim msg As String
  114.  
  115.     If Save = True Then
  116.         
  117.         ' One or more bound controls has changed, so verify that all fields
  118.         ' have legal entries. If a field has an incorrect value, set the
  119.         ' variable msg to a string explaining the error and set the focus
  120.         ' to that field to facilitate the user's correcting the error.
  121.         If txtTitle = "" Then
  122.              msg = "You must enter a title."
  123.              txtTitle.SetFocus
  124.         ElseIf txtISBN = "" Then
  125.              msg = "You must enter an ISBN."
  126.              txtISBN.SetFocus
  127.         ElseIf txtYearPublished <> "" And Not IsNumeric(txtYearPublished) Then
  128.             msg = "The Year Published must be numeric."
  129.             txtYearPublished.SetFocus
  130.         End If
  131.     End If
  132.     
  133.     If msg <> "" Then
  134.     
  135.         ' We have something in the variable msg, which means that an error
  136.         ' has occurred. Display the message for the user.
  137.         MsgBox msg, vbExclamation
  138.         
  139.         ' Cancel the Validate event
  140.         Action = vbDataActionCancel
  141.         
  142.         ' Set the form-level variable UpdateCancelled to True. This flags
  143.         ' the Unload event to cancel the unload.
  144.         UpdateCancelled = True
  145.         
  146.     Else
  147.     
  148.         ' No errors, so set the form level variable UpdateCancelled False
  149.         ' to flag the Unload event to go ahead and proceed with the unload.
  150.         UpdateCancelled = False
  151.     End If
  152. End Sub
  153.  
  154. Private Sub Form_Unload(Cancel As Integer)
  155.  
  156.     ' If the Validate event set the UpdateCancelled flag, cancel the unload.
  157.     If UpdateCancelled Then Cancel = True
  158.  
  159. End Sub
  160.  
  161. Private Sub mnuFileExit_Click()
  162.     Unload Me
  163. End Sub
  164.  
  165.  
  166.  
  167.